|
|
|
|
|
|
|
Rectangle and RoundRect Functions |
|
|
|
|
|
|
|
|
The Rectangle and RoundRect functions draw rectangles and rounded rectangles similar to those produced by the Visual Basic Shape control. |
|
|
|
 |
|
|
|
|
Private Declare Function Rectangle Lib "gdi32" _
Alias "Rectangle" (ByVal hdc As Long, _
ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function RoundRect Lib "gdi32" _
Alias "RoundRect" (ByVal hdc As Long, -
ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long, _
ByVal nWidth As Long, ByVal nHeight As Long) As Long |
|
|
|
|
|
|
|
|
The Rectangle function draws a rectangle with opposite corners at coordinates (X1, Y1) and (X2, Y2). The RoundRect function draws a similar rectangle with the corners rounded to follow a quarter of an ellipse. The nWidth and nHeight arguments specify the width and height of the ellipses that are used in rounding the corners. Figure 2.6 shows how these parameters determine the shape of the rounded rectangle. |
|
|
|
|
|
|
|
|
Example program Rect, shown in Figure 2.7, demonstrates the Rectangle and RoundRect functions. Whenever the program's form is resized, including when it is first created, the program draws several rectangles and rounded rectangles. |
|
|
|
|
|
|
|
|
The Ellipse, Arc, Chord, and Pie functions draw pieces of ellipses in different styles. |
|
|
|
 |
|
|
|
|
Private Declare Function Ellipse Lib "gdi32" _
Alias "Ellipse" (ByVal hdc As Long, _ |
|
|
|
|
|
|
|
|
Figure 2.6
A rounded rectangle drawn by RoundRect. |
|
|
|
|
|